package main

import "fmt"

// Person类，绑定方法：Eat,Run,Laugh,成员
/*class Person {
	Public:
		string name
		int age
	Public:
		Eat(){
			xxx
		}
	}
}*/

type Person struct {
	name   string
	age    int
	gender string
	score  float64
}

// 在类外面绑定方法
func (this *Person) Eat() {
	fmt.Println("Person is eating")
	//类的方法，可以使用自己的成员
	//fmt.Println(this.name + " is eating")
	this.name = "Duke"
}
func (this Person) Eat2() {
	fmt.Println("Person is eating")
	//类的方法，可以使用自己的成员
	this.name = "Duke"
	//fmt.Println(this.name + " is eating")
}
func main() {
	lily := Person{
		name:   "Lily",
		age:    20,
		gender: "male",
		score:  1.0,
	}
	lily1 := lily
	fmt.Println("Eat,使用p *Person,但不是指针", lily)
	fmt.Println("修改前lily", lily)
	lily.Eat()
	fmt.Println("修改后lily", lily)

	fmt.Println("Eat2，使用p Person,但不是指针")
	fmt.Println("修改前lily1", lily1)
	lily.Eat2()
	fmt.Println("修改后lily1", lily1)
}
